#include <vector>
#include <fstream>
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
  // 输入
  ifstream ifs("OutOfPlace.in");

  int n = 0;
  ifs >> n; // 有多少头牛

  vector<int> heights;
  for (int i = 0; i < n; ++i) {
    int h = 0;
    ifs >> h;
    heights.push_back(h);
  }

  vector<int> sortedHeights(heights);
  sort(sortedHeights.begin(), sortedHeights.end(), greater<int>());

  int count = 0;

  for (int i =0; i < n; ++i) {
    if (heights[i] != sortedHeights[i]) {
      ++count; // heights 和 sortedHeights 这两个数组的差异
    }
  }

  --count;

  ofstream ofs("OutOfPlace.out");
  ofs << count;

  return 0;
}
